﻿<Window x:Class="SmallProgram.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:avalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
        Title="Small Program" Height="600" Width="800" 
        Icon="/SmallProgram;component/app.ico" xmlns:my="clr-namespace:SmallProgram.Controls;assembly=SmallProgram.Controls">
    <Window.CommandBindings>
        <CommandBinding Command="New" Executed="FileNewClick"></CommandBinding>
        <CommandBinding Command="Open" Executed="FileOpenClick"></CommandBinding>
        <CommandBinding Command="Save" Executed="FileSaveClick"></CommandBinding>
        <CommandBinding Command="Find" Executed="Find"></CommandBinding>
    </Window.CommandBindings>
    <Window.InputBindings>
        <KeyBinding Command="New" Gesture="Ctrl+N" />
        <KeyBinding Command="Open" Gesture="Ctrl+O" />
        <KeyBinding Command="Save" Gesture="Ctrl+S" />
        <KeyBinding Command="Find" Gesture="Ctrl+F" />
    </Window.InputBindings>
    <Grid>
        <DockPanel>
            <ToolBar DockPanel.Dock="Top">
                <ToolBar.Resources>
                    <Style TargetType="{x:Type Image}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ButtonBase}, AncestorLevel=1}, Path=IsEnabled}" Value="False">
                                <Setter Property="Opacity" Value="0.30" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ToolBar.Resources>
                <Button Click="FileNewClick">
                    <Image Source="Resources/filenew.png" Height="32" />
                </Button>
                <Button Click="FileOpenClick">
                    <Image Source="Resources/fileopen.png" Height="32"/>
                </Button>
                <Button Click="FileSaveClick">
                    <Image Source="Resources/filesave.png" Height="32"/>
                </Button>
                <Button Click="FileSaveasClick">
                    <Image Source="Resources/filesaveas.png" Height="32"/>
                </Button>
                <Separator/>
                <Button Click="WebOpenClick">
                    <Image Source="Resources/webopen.png" Height="32"/>
                </Button>
                <Button Click="WebSaveClick">
                    <Image Source="Resources/websave.png" Height="32"/>
                </Button>
                <Separator/>
                <Button Command="Cut">
                    <Image Source="Resources/editcut.png" Height="32"/>
                </Button>
                <Button Command="Copy">
                    <Image Source="Resources/editcopy.png" Height="32"/>
                </Button>
                <Button Command="Paste">
                    <Image Source="Resources/editpaste.png" Height="32"/>
                </Button>
                <Separator/>
                <Button Command="Undo">
                    <Image Source="Resources/editundo.png" Height="32"/>
                </Button>
                <Button Command="Redo">
                    <Image Source="Resources/editredo.png" Height="32"/>
                </Button>
                <Separator/>
                <Button Click="Run">
                    <Image Source="Resources/programrun.png" Height="32"/>
                </Button>
                <Button Click="Export">
                    <Image Source="Resources/export.png" Height="32"/>
                </Button>
                <Separator />
                <CheckBox IsChecked="{Binding ElementName=textEditor,Path=ShowLineNumbers}" Visibility="Hidden">
                    <TextBlock Width="32" Height=" 32" VerticalAlignment="Center" TextAlignment="Center">#</TextBlock>
                </CheckBox>
            </ToolBar>
            <Grid x:Name="gridMain">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>                
                <avalonEdit:TextEditor
				Name="textEditor"
				FontFamily="Consolas"
				FontSize="11pt"
				SyntaxHighlighting="C#">
                </avalonEdit:TextEditor>
                <my:ErrorListControl Name="errorListControl" Height="0.0" VerticalAlignment="Bottom" Grid.Row="1" />
            </Grid>
        </DockPanel>
        <Grid x:Name="programRunningOverlay" Visibility="Hidden">
            <Grid.Background>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Color="#cc000000" Offset="0" />
                    <GradientStop Color="#cc333363" Offset="1" />
                </LinearGradientBrush>
            </Grid.Background>
            <DockPanel>
                <StackPanel DockPanel.Dock="Bottom">
                    <Button Name="endProgramButton" Padding="4" Margin="8" FontWeight="Bold" HorizontalAlignment="Right"  IsDefault="true" Content="End Program" Click="OnProgramEnd" />
                </StackPanel>
                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
                    <TextBlock Name="processRunningMessage" TextAlignment="Center" Margin="8" FontWeight="Bold" FontSize="32" Foreground="#649Db4" TextWrapping="WrapWithOverflow" />
                    <TextBlock TextAlignment="Center" Margin="8" FontSize="24" Foreground="#999999" TextWrapping="WrapWithOverflow" Text="You can either wait for your program to complete, or you can click the 'End Program' button to close your program and get back to editing." />
                    <TextBlock TextAlignment="Center" Margin="8" FontSize="12" Foreground="White" FontWeight="Bold" TextWrapping="WrapWithOverflow" Text="This overlay will close automatically when your program ends." />
                </StackPanel>
            </DockPanel>
        </Grid>
    </Grid>
</Window>
